<html>
<head>
  <meta NAME="author" CONTENT="Tamas Vertse">
  <link REL ="stylesheet" TYPE="text/css" HREF="../../../marvinmanuals.css" TITLE="Style">
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  <title>MarvinView Example - Loading molecules from an SD file to a molecule table</title>

</head>
<body onLoad="links_set_search(location.search)">

<h1>MarvinView Example - Loading molecules from an SD file to a molecule table</h1>
This example demonstrates the way of loading structures from an SD file to a
scrollable molecule table.

<center>
<script LANGUAGE="JavaScript1.1" SRC="../../../marvin.js"></script>
<script LANGUAGE="JavaScript1.1"><!--
// number of structures in the SD file
var max = 8;

var col = 2;
var row;
var vcol = 2;
var vrow = 2;
if(max < 2) {
    col = 1;
    row = 1;
} else {
    row = Math.floor((max + 1) / col);

}
if(vcol > col) {
    vcol = col;
}
if(vrow > row) {
    vrow = row;
}
mview_name="MView"
mview_begin("../../..",430,440);
if(max > 1) {
    mview_param("rows",row)
    mview_param("cols",col)
    mview_param("visibleCols",vcol)
    mview_param("visibleRows",vrow)
    mview_param("border",1)
    mview_param("layout",":2:1:M:1:0:1:1:c:b:1:1:L:0:0:1:1:c:n:0:1")
    mview_param("param",":M:200:200:L:10b")
    for(i=0;i<(row*col);i++) {
        mview_param("cell"+i,"||"+(i+1))
    }
}
mview_param("mol","../../../mols-2d/mols.sdf");
mview_end();
//--></script>
</center>

<p>The number of cells is 8 (4 rows and 2 columns). From the specified SD file,
 (the first) 8 structures are loaded into the table.
<blockquote>
<pre>
<strong>&lt;script LANGUAGE</strong>=&quot;JavaScript1.1&quot; <strong>SRC</strong>=&quot;../../../<a href="../marvin.js.txt">marvin.js</a>&quot;<strong>&gt;&lt;/script&gt;</strong>
<strong>&lt;script LANGUAGE</strong>=&quot;JavaScript1.1&quot;<strong>&gt;</strong>
&lt;!--
// number of structures in the SD file
var max = 8;

var col = 2;
var vcol = 2;
var vrow = 2;
if(max &lt; 2) {
    col = 1;
    row = 1;
} else {
    row = Math.floor((max + 1) / col);

}
if(vcol &gt; col) {
    vcol = col;
}
if(vrow &gt; row) {
    vrow = row;
}
<strong>mview_name</strong>=&quot;MView&quot;
<strong>mview_begin(</strong>&quot;../../..&quot;,430,440<strong>)</strong>;
if(max &gt; 1) {
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.rows">rows</a>&quot;,row<strong>)</strong>
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.cols">cols</a>&quot;,col<strong>)</strong>
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.visibleCols">visibleCols</a>&quot;,vcol<strong>)</strong>
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.visibleRows">visibleRows</a>&quot;,vrow<strong>)</strong>
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.border">border</a>&quot;,1<strong>)</strong>
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.layout">layout</a>&quot;,&quot;:2:1:M:1:0:1:1:c:b:1:1:L:0:0:1:1:c:n:0:1&quot;<strong>)</strong>
    <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.param">param</a>&quot;,&quot;:M:200:200:L:10b&quot;<strong>)</strong>
    for(i=0;i&lt;(row*col);i++) {
        <strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#advanced.cell">cell</a>&quot;+i,&quot;||&quot;+(i+1)<strong>)</strong>
    }
}
<strong>mview_param(</strong>&quot;<a href="../../../help/developer/viewman.html#parameters.mol">mol</a>&quot;,&quot;../../mols-2d/mols.sdf&quot;<strong>)</strong>
<strong>mview_end()</strong>
//--&gt;<strong>&lt;/script&gt;</strong>
</pre>
</blockquote>
<p>
The <em>max</em> variable determines the number of cells in the molecule table.
Based on its value, we can calculate the parameters of the molecule
table (<em>rows</em>, <em>cols</em>, <em>visibleCols</em>,
<em>visibleRows</em>).<br>

The <em>cell0</em>,<em>cell1</em>,... parameters set
the content of the cells. But the molecules are specified later, by using
the <em>mol</em> parameter.
This parameter specifies the input file containing the structures for the
 cells.</p>

<p>This code is easy to extend. By changing the value of the
<em>max</em> variable and the <em>mol</em> applet parameter, you can use this
example to display another SD file. If you want to load all structures from
an SD file, you have to know the number of structures in the file to
correctly initialize the applet.</p>

<p>The <a href="transfering.html">next example</a> shows how to alter the structures of the table with MarvinSketch.</p>
</body>
</html>
